<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>领取优惠券</title>
  <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
  <meta content="yes" name="apple-mobile-web-app-capable"/>
  <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
  <meta content="telephone=no" name="format-detection"/>
  <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script src="__STATIC__/layer/layer.js"></script>
</head>
<body>
{if condition="$result == 1"}
  {foreach name="coupon" item="v"}
{if condition="$v.is_received eq 0"}
      <div>
        <img src="{$v.img}" width="200px;" height="100px;">
        <span>￥{$v.reduce}</span>&nbsp;&nbsp;
        <span>满￥{$v.morethan}元，减￥{$v.reduce}</span>&nbsp;&nbsp;
        <a href="javascript:;" onclick="receive(this,{$v.id});">领取</a>
      </div>
{/if}
  {/foreach}
{else /}
  没有可领取的优惠券
{/if}
</body>
</html>
<script>
  /**
   * 领取优惠券
   */
  function receive(obj,id){
      var receive_order_id = "{$receive_order_id}";
      $.post("{:url('PayComplete/get_coupon')}",
          {id:id,receive_order_id:receive_order_id},
          function(data){
              if(data.code == 1){
                  alert('领取成功');
                  $(obj).parent().remove();
              }else{
                  alert('领取失败');
              }
          }
      );
  }
</script>